#!/bin/bash

# MySQL 初始化脚本
echo "开始初始化 MySQL 数据库..."

# 创建数据库
mysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "
  CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE}_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}_test.* TO '${MYSQL_USER}'@'%';
  FLUSH PRIVILEGES;
"

echo "MySQL 初始化完成"